package com.atguigu;

import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;
import java.util.Enumeration;

@WebServlet("/servlet3")
public class servlet3  extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ServletContext servletContext1 = req.getServletContext();
        ServletContext servletContext2 = getServletContext();
        ServletContext servletContext3 = getServletConfig().getServletContext();
        System.out.println(servletContext1==servletContext2);
        System.out.println(servletContext2==servletContext3);
        Enumeration<String> initParameterNames = servletContext1.getInitParameterNames();
        while(initParameterNames.hasMoreElements()){
            String s = initParameterNames.nextElement();
            System.out.println(s+" = "+servletContext1.getInitParameter(s));
        }
    }
}
